package cn.com.pc.penguin.servlet;

import cn.com.pc.penguin.utils.SpringBeanUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

public class StartupServlet extends HttpServlet implements
        ServletContextListener {

	private final static Log log = LogFactory.getLog(StartupServlet.class);
	private static final long serialVersionUID = 1L;

	public void destroy() {
		super.destroy(); 		
	}
	
	public void init() throws ServletException {
System.out.println("here .........");		
		ServletContext context = getServletContext();
	    WebApplicationContext appCtx = WebApplicationContextUtils.getWebApplicationContext(context);
	    SpringBeanUtil.setAppCtx(appCtx);
	    
	}

	public void contextDestroyed(ServletContextEvent sce) {
		
	}

	public void contextInitialized(ServletContextEvent sce) {
		
	}

}
